package com.tj.collection.controller.switchs;

import com.fqgj.msg.utils.Paged;
import com.tj.collection.common.Result;
import com.tj.collection.controller.switchs.request.SwitchManageAddOrUpdateRequest;
import com.tj.collection.controller.switchs.request.SwitchManageQueryRequest;
import com.tj.collection.controller.switchs.response.SwitchManagerResponse;
import com.tj.collection.db.service.SwitchManageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName: SwitchManageController
 * @description: 开关隐藏相关管理
 * @author: yuwn
 * @create: 2023-11-23 14:09
 */
@RestController
@RequestMapping("/switchManage")
@Api(value = "开关隐藏相关管理", tags = {"开关隐藏相关管理"})
public class SwitchManageController {


    @Autowired
    private SwitchManageService switchManageService;

    @ApiOperation("开关管理列表")
    @RequestMapping(value = "/getList", method = {RequestMethod.POST})
    public Result<Paged<List<SwitchManagerResponse>>> getList(@RequestBody SwitchManageQueryRequest queryDTO){

        return Result.ok(switchManageService.getList(queryDTO));
    }


    @ApiOperation("开关管理新增或者修改")
    @RequestMapping(value = "/addOrUpdate", method = {RequestMethod.POST})
    public Result<Boolean> addOrUpdate(@RequestBody SwitchManageAddOrUpdateRequest addOrUpdateDto){

        return Result.ok(switchManageService.addOrUpdate(addOrUpdateDto));
    }

    @ApiOperation("开关管理删除")
    @RequestMapping(value = "/delete/{id}", method = {RequestMethod.GET})
    public Result<Boolean> delete(@PathVariable("id") Long id){

        return Result.ok(switchManageService.deleteById(id));
    }

    @ApiOperation("现有包名列表")
    @RequestMapping(value = "/getPackageList/{switchType}", method = {RequestMethod.GET})
    public Result<List<String>> getPackageList(@PathVariable("switchType") Integer switchType){

        return Result.ok(switchManageService.getPackageList(switchType));
    }

}
